define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'litestore/goods_evaluate/index' + location.search,
                    add_url: 'litestore/goods_evaluate/add',
                    edit_url: 'litestore/goods_evaluate/edit',
                    del_url: 'litestore/goods_evaluate/del',
                    multi_url: 'litestore/goods_evaluate/multi',
                    import_url: 'litestore/goods_evaluate/import',
                    table: 'litestore_goods_evaluate',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search: false,
                searchFormVisible: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        // {field: 'user_id', title: __('User_id')},
                        {field: 'nickname', title: __('Nickname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'order_id', title: __('Order_id')},
                        // {field: 'order_goods_id', title: __('Order_goods_id')},
                        // {field: 'goods_id', title: __('Goods_id')},
                        // {field: 'spec_sku_id', title: __('Spec_sku_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'goods_spec_image', title: __('Goods_spec_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'goods_name', title: __('Goods_name'), operate: 'LIKE'},
                        // {field: 'goods_spec_id', title: __('Goods_spec_id')},
                        {field: 'goods_attr', title: __('Goods_attr'), operate: false},
                        {field: 'goods_price', title: __('Goods_price'), operate: false},
                        // {field: 'goods_no', title: __('Goods_no'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'content', title: __('Content'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'scores', title: __('Scores'), operate: false},
                        {field: 'delivery_service', title: __('Delivery_service'), operate: false},
                        {field: 'service_attitude', title: __('Service_attitude'), operate: false},
                        {field: 'is_anonymous', title: __('Is_anonymous'), searchList: {"0":__('Is_anonymous 0'),"1":__('Is_anonymous 1')}, formatter: Table.api.formatter.label},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                        // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
